﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using QLTV_Public;

namespace QLTV_Data
{
   public class MuonTra_Data
    {
       KetNoiCSDL_Data kn = new KetNoiCSDL_Data();
       public DataTable taobang(string sql)
       {
           return kn.taobang(sql);
       }
       public DataTable Load_MuonQuaHan()
       {
           return kn.taobang("Load_MuonQuaHan");
       }
       public DataTable Load_tbl_MuonTra()
       {
           return kn.taobang("Load_tbl_MuonTra");
       }
       public DataTable Load_MuonTra_DaTra()
       {
           return kn.LayDuLieu("Load_MuonTra_DaTra");
       }
       public DataTable Load_MuonTra_DangMuon()
       {
           return kn.LayDuLieu("Load_MuonTra_DangMuon");
       }
       public int Insert_MuonTra(MuonTra_Public maPhieuMuon,MuonTra_Public maTaiLieu,MuonTra_Public ngayMuon,MuonTra_Public hanTra,MuonTra_Public TrangThai,MuonTra_Public maNV)
       {
           int Nparameter = 6;
           string[]name=new string[Nparameter];
           object[]value=new object[Nparameter];
           name[0]="@MaPhieuMuon";
           value[0] = maPhieuMuon.MaPhieuMuon;
           name[1] = "@MaTaiLieu";
           value[1] = maTaiLieu.MaTaiLieu;
           name[2] = "@NgayMuon";
           value[2] = ngayMuon.NgayMuon;
           name[3] = "@HanTra";
           value[3] = hanTra.HanTra;
           name[4] = "@TrangThai";
           value[4] = TrangThai.TrangThai;
           name[5] = "@MaNV";
           value[5] = maNV.MaNV;
           return kn.update("Insert_MuonTra",name,value,Nparameter);
       }
       public int Update_MuonTra(MuonTra_Public maPhieuMuon, MuonTra_Public maTaiLieu, MuonTra_Public ngayMuon, MuonTra_Public hanTra,MuonTra_Public ngayTra, MuonTra_Public TrangThai,MuonTra_Public maNV)
       {
           int Nparameter =7;
           string[] name = new string[Nparameter];
           object[] value = new object[Nparameter];
           name[0] = "@MaPhieuMuon";
           value[0] = maPhieuMuon.MaPhieuMuon;
           name[1] = "@MaTaiLieu";
           value[1] = maTaiLieu.MaTaiLieu;
           name[2] = "@NgayMuon";
           value[2] = ngayMuon.NgayMuon;
           name[3] = "@HanTra";
           value[3] = hanTra.HanTra;
           name[4] = "@NgayTra";
           value[4] = ngayTra.NgayTra;
           name[5] = "@TrangThai";
           value[5] = TrangThai.TrangThai;
           name[6] = "@MaNV";
           value[6] = maNV.MaNV;
           return kn.update("Update_MuonTra", name, value, Nparameter);
       }
       public int Delete_MuonTra(MuonTra_Public maPhieuMuon, MuonTra_Public maTaiLieu)
       {
           int Nparameter = 2;
           string[] name = new string[Nparameter];
           object[] value = new object[Nparameter];
           name[0] = "@MaPhieuMuon";
           value[0] = maPhieuMuon.MaPhieuMuon;
           name[1] = "@MaTaiLieu";
           value[1] = maTaiLieu.MaTaiLieu;
           return kn.update("Delete_MuonTra", name, value, Nparameter);
       }
       public int Update_MuonTra_TrangThai(MuonTra_Public maPhieuMuon,MuonTra_Public maTaiLieu,MuonTra_Public ngayTra,MuonTra_Public trangThai)
       {
           int Nparameter = 4;
           string[] name = new string[Nparameter];
           object[] value = new object[Nparameter];
           name[0] = "@MaPhieuMuon";
           value[0] = maPhieuMuon.MaPhieuMuon;
           name[1] = "@MaTaiLieu";
           value[1] = maTaiLieu.MaTaiLieu;
           name[2] = "@NgayTra";
           value[2] = ngayTra.NgayTra;
           name[3] = "@TrangThai";
           value[3] = trangThai.TrangThai;
           return kn.update("Update_tbl_MuonTra_TraSach", name, value, Nparameter);
       }
       public DataTable TraSach(DocGia_Public maDocGia)
       {
           int n = 1;
           string[]name= new string[n];
           object[] value = new object[n];
           name[0] = "@MaDocGia";
           value[0] = maDocGia.MaDocGia;
           return kn.LayDuLieu("TraSach",name,value,n);
       }
    }
}
